package br.com.projetojsf.spring;

import org.hibernate.SessionFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class SpringAccess {

	private static ApplicationContext springContext;
	
	
	public static synchronized ApplicationContext getSpringContext(){
		
		if(springContext == null)
			springContext = new ClassPathXmlApplicationContext("/applicationContext.xml");
		
		
		return springContext;
	}
	
	public static synchronized SessionFactory getSessionFactory(){
		
		return (SessionFactory) getSpringContext().getBean("hibernate");
	}
	
	public SpringAccess (){
		
	}
	
}
